<template>
  <div class="app-container">
    <!-- 高级查询 -->
    <el-form v-show="searchVisible" ref="queryForm" :model="queryParams" :inline="true">
      <el-form-item label=":">
        <el-input v-model="queryParams.purchaseOrderNo" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.supplierNo" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="销售订单号:">
        <el-input v-model="queryParams.salesOrderNo" size="small" placeholder="请输入销售订单号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="客户ID:">
        <el-input v-model="queryParams.customerId" size="small" placeholder="请输入客户ID" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="客户名称:">
        <el-input v-model="queryParams.customerName" size="small" placeholder="请输入客户名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="用户名称:">
        <el-input v-model="queryParams.userName" size="small" placeholder="请输入用户名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="优惠金额:">
        <el-input v-model="queryParams.preMoney" size="small" placeholder="请输入优惠金额" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="运费:">
        <el-input v-model="queryParams.freightFee" size="small" placeholder="请输入运费" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="销售员ID:">
        <el-input v-model="queryParams.salesManId" size="small" placeholder="请输入销售员ID" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="销售员:">
        <el-input v-model="queryParams.salesMan" size="small" placeholder="请输入销售员" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="优惠券ID:">
        <el-input v-model="queryParams.couponId" size="small" placeholder="请输入优惠券ID" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="优惠券抵扣金额:">
        <el-input v-model="queryParams.couponAmount" size="small" placeholder="请输入优惠券抵扣金额" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="数量合计:">
        <el-input v-model="queryParams.totalQty" size="small" placeholder="请输入数量合计" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="金额合计:">
        <el-input v-model="queryParams.totalMoney" size="small" placeholder="请输入金额合计" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="收货人:">
        <el-input v-model="queryParams.receiver" size="small" placeholder="请输入收货人" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="收货人手机:">
        <el-input v-model="queryParams.receiverPhone" size="small" placeholder="请输入收货人手机" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="收货人省:">
        <el-input v-model="queryParams.receiverProvince" size="small" placeholder="请输入收货人省" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="收货人市:">
        <el-input v-model="queryParams.receiverCity" size="small" placeholder="请输入收货人市" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="收货人区:">
        <el-input v-model="queryParams.receiverDistrict" size="small" placeholder="请输入收货人区" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="收货人地址:">
        <el-input v-model="queryParams.receiverAddress" size="small" placeholder="请输入收货人地址" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="买家留言:">
        <el-input v-model="queryParams.buyerMessage" size="small" placeholder="请输入买家留言" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="提案文件地址:">
        <el-input v-model="queryParams.quoteUrl" size="small" placeholder="请输入提案文件地址" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="确认提案时间:">
        <el-date-picker v-model="queryParams.confirmQuoteTime" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择确认提案时间" clearable />
      </el-form-item>
      <el-form-item label="是否评价:">
        <el-input v-model="queryParams.buyerRate" size="small" placeholder="请输入是否评价" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="交易流水号:">
        <el-input v-model="queryParams.transactionId" size="small" placeholder="请输入交易流水号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="预付单号:">
        <el-input v-model="queryParams.prepayId" size="small" placeholder="请输入预付单号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="预付微信openid:">
        <el-input v-model="queryParams.prepayOpenid" size="small" placeholder="请输入预付微信openid" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="预付单号生成时间:">
        <el-date-picker v-model="queryParams.prepayTime" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择预付单号生成时间" clearable />
      </el-form-item>
      <el-form-item label="实付金额:">
        <el-input v-model="queryParams.payMoney" size="small" placeholder="请输入实付金额" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="付款时间:">
        <el-date-picker v-model="queryParams.payTime" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择付款时间" clearable />
      </el-form-item>
      <el-form-item label="物流单号:">
        <el-input v-model="queryParams.expressNo" size="small" placeholder="请输入物流单号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="物流公司名称:">
        <el-input v-model="queryParams.expressCompanyName" size="small" placeholder="请输入物流公司名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="发货时间:">
        <el-date-picker v-model="queryParams.deliveryTime" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择发货时间" clearable />
      </el-form-item>
      <el-form-item label="工作流实例ID:">
        <el-input v-model="queryParams.procInsId" size="small" placeholder="请输入工作流实例ID" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="主管审核:">
        <el-input v-model="queryParams.supervisorAuditBy" size="small" placeholder="请输入主管审核" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="部门经理审核:">
        <el-input v-model="queryParams.deptManagerAuditBy" size="small" placeholder="请输入部门经理审核" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="总经理审核备注:">
        <el-input v-model="queryParams.generalManagerAuditRemark" size="small" placeholder="请输入总经理审核备注" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="交易完成时间:">
        <el-date-picker v-model="queryParams.endTime" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择交易完成时间" clearable />
      </el-form-item>
      <el-form-item label="交易关闭时间:">
        <el-date-picker v-model="queryParams.closeTime" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择交易关闭时间" clearable />
      </el-form-item>
      <el-form-item label="所属店铺ID:">
        <el-input v-model="queryParams.storeId" size="small" placeholder="请输入所属店铺ID" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.custSalesOrderNo" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="店铺来源:">
        <el-input v-model="queryParams.storeSource" size="small" placeholder="请输入店铺来源" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.site" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.importErrorMesg" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.errorFlag" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.errorCode" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.creditBillNo" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.contractNo" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <!-- 工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button v-hasPermission="['order:purchaseOrder:insert']" type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-hasPermission="['order:purchaseOrder:update']" type="success" icon="el-icon-edit" size="mini" :disabled="isSingle" @click="handleEdit">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-hasPermission="['order:purchaseOrder:delete']" type="danger" icon="el-icon-delete" size="mini" :disabled="isMultiple" @click="handleRemove">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-hasPermission="['order:purchaseOrder:export']" type="warning" icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
      </el-col>
      <right-toolbar :show-search.sync="searchVisible" @queryTable="handleQuery" />
    </el-row>

    <!-- 数据列表 -->
    <el-table v-loading="loading" :data="page.records" highlight-current-row @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="ID" align="center" prop="id" />
      <el-table-column label="" align="center" prop="purchaseOrderNo" />
      <el-table-column label="" align="center" prop="supplierNo" />
      <el-table-column label="销售订单号" align="center" prop="salesOrderNo" />
      <el-table-column label="订单类型" align="center" prop="orderType" />
      <el-table-column label="订单来源" align="center" prop="sourceType" />
      <el-table-column label="客户ID" align="center" prop="customerId" />
      <el-table-column label="客户名称" align="center" prop="customerName" />
      <el-table-column label="用户名称" align="center" prop="userName" />
      <el-table-column label="优惠金额" align="center" prop="preMoney" />
      <el-table-column label="运费" align="center" prop="freightFee" />
      <el-table-column label="销售员ID" align="center" prop="salesManId" />
      <el-table-column label="销售员" align="center" prop="salesMan" />
      <el-table-column label="优惠券ID" align="center" prop="couponId" />
      <el-table-column label="优惠券抵扣金额" align="center" prop="couponAmount" />
      <el-table-column label="数量合计" align="center" prop="totalQty" />
      <el-table-column label="金额合计" align="center" prop="totalMoney" />
      <el-table-column label="收货人" align="center" prop="receiver" />
      <el-table-column label="收货人手机" align="center" prop="receiverPhone" />
      <el-table-column label="收货人省" align="center" prop="receiverProvince" />
      <el-table-column label="收货人市" align="center" prop="receiverCity" />
      <el-table-column label="收货人区" align="center" prop="receiverDistrict" />
      <el-table-column label="收货人地址" align="center" prop="receiverAddress" />
      <el-table-column label="买家留言" align="center" prop="buyerMessage" />
      <el-table-column label="提案文件地址" align="center" prop="quoteUrl" />
      <el-table-column label="确认提案时间" align="center" prop="confirmQuoteTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.confirmQuoteTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否评价" align="center" prop="buyerRate" />
      <el-table-column label="交易流水号" align="center" prop="transactionId" />
      <el-table-column label="支付类型，1、在线支付、0 货到付款" align="center" prop="payType" />
      <el-table-column label="预付单号" align="center" prop="prepayId" />
      <el-table-column label="预付微信openid" align="center" prop="prepayOpenid" />
      <el-table-column label="预付单号生成时间" align="center" prop="prepayTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.prepayTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="实付金额" align="center" prop="payMoney" />
      <el-table-column label="付款时间" align="center" prop="payTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.payTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="支付状态" align="center" prop="payStatus" />
      <el-table-column label="物流单号" align="center" prop="expressNo" />
      <el-table-column label="物流公司名称" align="center" prop="expressCompanyName" />
      <el-table-column label="发货时间" align="center" prop="deliveryTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.deliveryTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="发货状态" align="center" prop="deliveryStatus" />
      <el-table-column label="订单状态" align="center" prop="orderStatus" />
      <el-table-column label="工作流实例ID" align="center" prop="procInsId" />
      <el-table-column label="主管审核" align="center" prop="supervisorAuditBy" />
      <el-table-column label="主管审核备注" align="center" prop="supervisorAuditRemark" />
      <el-table-column label="部门经理审核" align="center" prop="deptManagerAuditBy" />
      <el-table-column label="部门经理审核备注" align="center" prop="deptManagerAuditRemark" />
      <el-table-column label="总经理审核" align="center" prop="generalManagerAuditBy" />
      <el-table-column label="总经理审核备注" align="center" prop="generalManagerAuditRemark" />
      <el-table-column label="交易完成时间" align="center" prop="endTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="交易关闭时间" align="center" prop="closeTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.closeTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="所属店铺ID" align="center" prop="storeId" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="" align="center" prop="custSalesOrderNo" />
      <el-table-column label="店铺来源" align="center" prop="storeSource" />
      <el-table-column label="" align="center" prop="site" />
      <el-table-column label="" align="center" prop="importErrorMesg" />
      <el-table-column label="" align="center" prop="errorFlag" />
      <el-table-column label="" align="center" prop="errorCode" />
      <el-table-column label="" align="center" prop="creditBillNo" />
      <el-table-column label="" align="center" prop="contractNo" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button v-hasPermission="['order:purchaseOrder:update']" size="mini" type="text" icon="el-icon-edit" @click="handleEdit(scope.row)">修改</el-button>
          <el-button v-hasPermission="['order:purchaseOrder:delete']" size="mini" type="text" icon="el-icon-delete" @click="handleRemove(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页 -->
    <pagination v-show="page.total>0" :total="page.total" :page.sync="page.current" :limit.sync="page.pageSize" @pagination="handleQuery" />

    <!-- 添加/修改对话框 -->
    <el-dialog :title="purchaseOrderFormDialog.title" :visible.sync="purchaseOrderFormDialog.visible" :close-on-click-modal="false" :before-close="resetPurchaseOrderFormDialog" width="500px" append-to-body>
      <el-form ref="purchaseOrderForm" :model="purchaseOrderFormData" :rules="purchaseOrderFormRules" label-width="80px">
        <el-form-item label="" prop="purchaseOrderNo">
          <el-input v-model="purchaseOrderFormData.purchaseOrderNo" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="supplierNo">
          <el-input v-model="purchaseOrderFormData.supplierNo" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="销售订单号" prop="salesOrderNo">
          <el-input v-model="purchaseOrderFormData.salesOrderNo" placeholder="请输入销售订单号" />
        </el-form-item>
        <el-form-item label="客户ID" prop="customerId">
          <el-input v-model="purchaseOrderFormData.customerId" placeholder="请输入客户ID" />
        </el-form-item>
        <el-form-item label="客户名称" prop="customerName">
          <el-input v-model="purchaseOrderFormData.customerName" placeholder="请输入客户名称" />
        </el-form-item>
        <el-form-item label="用户名称" prop="userName">
          <el-input v-model="purchaseOrderFormData.userName" placeholder="请输入用户名称" />
        </el-form-item>
        <el-form-item label="优惠金额" prop="preMoney">
          <el-input v-model="purchaseOrderFormData.preMoney" placeholder="请输入优惠金额" />
        </el-form-item>
        <el-form-item label="运费" prop="freightFee">
          <el-input v-model="purchaseOrderFormData.freightFee" placeholder="请输入运费" />
        </el-form-item>
        <el-form-item label="销售员ID" prop="salesManId">
          <el-input v-model="purchaseOrderFormData.salesManId" placeholder="请输入销售员ID" />
        </el-form-item>
        <el-form-item label="销售员" prop="salesMan">
          <el-input v-model="purchaseOrderFormData.salesMan" placeholder="请输入销售员" />
        </el-form-item>
        <el-form-item label="优惠券ID" prop="couponId">
          <el-input v-model="purchaseOrderFormData.couponId" placeholder="请输入优惠券ID" />
        </el-form-item>
        <el-form-item label="优惠券抵扣金额" prop="couponAmount">
          <el-input v-model="purchaseOrderFormData.couponAmount" placeholder="请输入优惠券抵扣金额" />
        </el-form-item>
        <el-form-item label="数量合计" prop="totalQty">
          <el-input v-model="purchaseOrderFormData.totalQty" placeholder="请输入数量合计" />
        </el-form-item>
        <el-form-item label="金额合计" prop="totalMoney">
          <el-input v-model="purchaseOrderFormData.totalMoney" placeholder="请输入金额合计" />
        </el-form-item>
        <el-form-item label="收货人" prop="receiver">
          <el-input v-model="purchaseOrderFormData.receiver" placeholder="请输入收货人" />
        </el-form-item>
        <el-form-item label="收货人手机" prop="receiverPhone">
          <el-input v-model="purchaseOrderFormData.receiverPhone" placeholder="请输入收货人手机" />
        </el-form-item>
        <el-form-item label="收货人省" prop="receiverProvince">
          <el-input v-model="purchaseOrderFormData.receiverProvince" placeholder="请输入收货人省" />
        </el-form-item>
        <el-form-item label="收货人市" prop="receiverCity">
          <el-input v-model="purchaseOrderFormData.receiverCity" placeholder="请输入收货人市" />
        </el-form-item>
        <el-form-item label="收货人区" prop="receiverDistrict">
          <el-input v-model="purchaseOrderFormData.receiverDistrict" placeholder="请输入收货人区" />
        </el-form-item>
        <el-form-item label="收货人地址" prop="receiverAddress">
          <el-input v-model="purchaseOrderFormData.receiverAddress" placeholder="请输入收货人地址" />
        </el-form-item>
        <el-form-item label="买家留言" prop="buyerMessage">
          <el-input v-model="purchaseOrderFormData.buyerMessage" placeholder="请输入买家留言" />
        </el-form-item>
        <el-form-item label="提案文件地址" prop="quoteUrl">
          <el-input v-model="purchaseOrderFormData.quoteUrl" placeholder="请输入提案文件地址" />
        </el-form-item>
        <el-form-item label="确认提案时间" prop="confirmQuoteTime">
          <el-date-picker v-model="purchaseOrderFormData.confirmQuoteTime" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择确认提案时间" clearable />
        </el-form-item>
        <el-form-item label="是否评价" prop="buyerRate">
          <el-input v-model="purchaseOrderFormData.buyerRate" placeholder="请输入是否评价" />
        </el-form-item>
        <el-form-item label="交易流水号" prop="transactionId">
          <el-input v-model="purchaseOrderFormData.transactionId" placeholder="请输入交易流水号" />
        </el-form-item>
        <el-form-item label="预付单号" prop="prepayId">
          <el-input v-model="purchaseOrderFormData.prepayId" placeholder="请输入预付单号" />
        </el-form-item>
        <el-form-item label="预付微信openid" prop="prepayOpenid">
          <el-input v-model="purchaseOrderFormData.prepayOpenid" placeholder="请输入预付微信openid" />
        </el-form-item>
        <el-form-item label="预付单号生成时间" prop="prepayTime">
          <el-date-picker v-model="purchaseOrderFormData.prepayTime" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择预付单号生成时间" clearable />
        </el-form-item>
        <el-form-item label="实付金额" prop="payMoney">
          <el-input v-model="purchaseOrderFormData.payMoney" placeholder="请输入实付金额" />
        </el-form-item>
        <el-form-item label="付款时间" prop="payTime">
          <el-date-picker v-model="purchaseOrderFormData.payTime" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择付款时间" clearable />
        </el-form-item>
        <el-form-item label="物流单号" prop="expressNo">
          <el-input v-model="purchaseOrderFormData.expressNo" placeholder="请输入物流单号" />
        </el-form-item>
        <el-form-item label="物流公司名称" prop="expressCompanyName">
          <el-input v-model="purchaseOrderFormData.expressCompanyName" placeholder="请输入物流公司名称" />
        </el-form-item>
        <el-form-item label="发货时间" prop="deliveryTime">
          <el-date-picker v-model="purchaseOrderFormData.deliveryTime" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择发货时间" clearable />
        </el-form-item>
        <el-form-item label="工作流实例ID" prop="procInsId">
          <el-input v-model="purchaseOrderFormData.procInsId" placeholder="请输入工作流实例ID" />
        </el-form-item>
        <el-form-item label="主管审核" prop="supervisorAuditBy">
          <el-input v-model="purchaseOrderFormData.supervisorAuditBy" placeholder="请输入主管审核" />
        </el-form-item>
        <el-form-item label="主管审核备注" prop="supervisorAuditRemark">
          <el-input v-model="purchaseOrderFormData.supervisorAuditRemark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="部门经理审核" prop="deptManagerAuditBy">
          <el-input v-model="purchaseOrderFormData.deptManagerAuditBy" placeholder="请输入部门经理审核" />
        </el-form-item>
        <el-form-item label="部门经理审核备注" prop="deptManagerAuditRemark">
          <el-input v-model="purchaseOrderFormData.deptManagerAuditRemark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="总经理审核" prop="generalManagerAuditBy">
          <el-input v-model="purchaseOrderFormData.generalManagerAuditBy" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="总经理审核备注" prop="generalManagerAuditRemark">
          <el-input v-model="purchaseOrderFormData.generalManagerAuditRemark" placeholder="请输入总经理审核备注" />
        </el-form-item>
        <el-form-item label="交易完成时间" prop="endTime">
          <el-date-picker v-model="purchaseOrderFormData.endTime" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择交易完成时间" clearable />
        </el-form-item>
        <el-form-item label="交易关闭时间" prop="closeTime">
          <el-date-picker v-model="purchaseOrderFormData.closeTime" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择交易关闭时间" clearable />
        </el-form-item>
        <el-form-item label="所属店铺ID" prop="storeId">
          <el-input v-model="purchaseOrderFormData.storeId" placeholder="请输入所属店铺ID" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="purchaseOrderFormData.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="" prop="custSalesOrderNo">
          <el-input v-model="purchaseOrderFormData.custSalesOrderNo" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="店铺来源" prop="storeSource">
          <el-input v-model="purchaseOrderFormData.storeSource" placeholder="请输入店铺来源" />
        </el-form-item>
        <el-form-item label="" prop="site">
          <el-input v-model="purchaseOrderFormData.site" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="importErrorMesg">
          <el-input v-model="purchaseOrderFormData.importErrorMesg" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="errorFlag">
          <el-input v-model="purchaseOrderFormData.errorFlag" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="errorCode">
          <el-input v-model="purchaseOrderFormData.errorCode" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="creditBillNo">
          <el-input v-model="purchaseOrderFormData.creditBillNo" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="contractNo">
          <el-input v-model="purchaseOrderFormData.contractNo" placeholder="请输入" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="confirmPurchaseOrderFormDialog">确 定</el-button>
        <el-button @click="resetPurchaseOrderFormDialog">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import PurchaseOrderApi from '@/api/order/PurchaseOrderApi'

const defaultPurchaseOrderFormData = {
  purchaseOrderNo: null,

  supplierNo: null,

  salesOrderNo: null,

  orderType: null,

  sourceType: null,

  customerId: null,

  customerName: null,

  userName: null,

  preMoney: null,

  freightFee: null,

  salesManId: null,

  salesMan: null,

  couponId: null,

  couponAmount: null,

  totalQty: null,

  totalMoney: null,

  receiver: null,

  receiverPhone: null,

  receiverProvince: null,

  receiverCity: null,

  receiverDistrict: null,

  receiverAddress: null,

  buyerMessage: null,

  quoteUrl: null,

  confirmQuoteTime: null,

  buyerRate: null,

  transactionId: null,

  payType: null,

  prepayId: null,

  prepayOpenid: null,

  prepayTime: null,

  payMoney: null,

  payTime: null,

  payStatus: '0',

  expressNo: null,

  expressCompanyName: null,

  deliveryTime: null,

  deliveryStatus: '0',

  orderStatus: '0',

  procInsId: null,

  supervisorAuditBy: null,

  supervisorAuditRemark: null,

  deptManagerAuditBy: null,

  deptManagerAuditRemark: null,

  generalManagerAuditBy: null,

  generalManagerAuditRemark: null,

  endTime: null,

  closeTime: null,

  storeId: null,

  custSalesOrderNo: null,

  storeSource: null,

  site: null,

  importErrorMesg: null,

  errorFlag: null,

  errorCode: null,

  creditBillNo: null,

  contractNo: null,

}
export default {
  name: 'PurchaseOrderList',
  data() {
    return {
      options: {
        sysYnTypeOptions: this.$constant.sysYnTypeOptions
      },
      queryParams: {
        purchaseOrderNo: null,
        supplierNo: null,
        salesOrderNo: null,
        orderType: null,
        sourceType: null,
        customerId: null,
        customerName: null,
        userName: null,
        preMoney: null,
        freightFee: null,
        salesManId: null,
        salesMan: null,
        couponId: null,
        couponAmount: null,
        totalQty: null,
        totalMoney: null,
        receiver: null,
        receiverPhone: null,
        receiverProvince: null,
        receiverCity: null,
        receiverDistrict: null,
        receiverAddress: null,
        buyerMessage: null,
        quoteUrl: null,
        confirmQuoteTime: null,
        buyerRate: null,
        transactionId: null,
        payType: null,
        prepayId: null,
        prepayOpenid: null,
        prepayTime: null,
        payMoney: null,
        payTime: null,
        payStatus: null,
        expressNo: null,
        expressCompanyName: null,
        deliveryTime: null,
        deliveryStatus: null,
        orderStatus: null,
        procInsId: null,
        supervisorAuditBy: null,
        supervisorAuditRemark: null,
        deptManagerAuditBy: null,
        deptManagerAuditRemark: null,
        generalManagerAuditBy: null,
        generalManagerAuditRemark: null,
        endTime: null,
        closeTime: null,
        storeId: null,
        custSalesOrderNo: null,
        storeSource: null,
        site: null,
        importErrorMesg: null,
        errorFlag: null,
        errorCode: null,
        creditBillNo: null,
        contractNo: null,
        isValid: this.$constant.Y
      },
      page: {
        current: 1,
        pageSize: 10,
        total: 0,
        records: []
      },
      purchaseOrderFormDialog: {
        title: '',
        visible: false
      },
      purchaseOrderFormData: Object.assign({}, defaultPurchaseOrderFormData),
      purchaseOrderFormRules: {
      },
      loading: true,
      searchVisible: true,
      multipleSelection: [],
      isSingle: true,
      isMultiple: true
    }
  },
  created() {
    this.handleQuery()
    this.loadOptions()
  },
  methods: {
    loadOptions() {
    },
    handleAdd() {
      this.openPurchaseOrderFormDialog()
    },
    handleRemove(row) {
      const ids = row.id || this.multipleSelection.map(item => item.id)
      this.$confirm('是否确认删除数据?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        return PurchaseOrderApi.remove(ids)
      }).then(() => {
        this.handleQuery()
        this.$message.success('删除成功')
      })
    },
    handleEdit(row) {
      const id = row.id || this.multipleSelection.map(item => item.id)[0]
      this.openPurchaseOrderFormDialog(id)
    },
    handleQuery() {
      this.loading = true
      PurchaseOrderApi.page(this.queryParams, this.page).then(response => {
        this.page.records = response.data.records
        this.page.total = response.data.total
        this.loading = false
      }, () => {
        this.loading = false
      })
    },
    handleExport() {
      this.$confirm('是否确认导出数据?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        return PurchaseOrderApi.exportData(this.queryParams)
      }).then(response => {
        this.$common.download(response.msg)
      })
    },
    openPurchaseOrderFormDialog(id) {
      this.purchaseOrderFormDialog.visible = true
      if (id) {
        this.purchaseOrderFormDialog.title = '采购订单-修改'
        PurchaseOrderApi.get(id).then(response => {
          this.purchaseOrderFormData = {
            ...this.purchaseOrderFormData,
            ...response.data
          }
        })
      } else {
        this.purchaseOrderFormDialog.title = '采购订单-添加'
      }
    },
    confirmPurchaseOrderFormDialog() {
      this.$refs['purchaseOrderForm'].validate(valid => {
        if (valid) {
          if (this.purchaseOrderFormData.id) {
            PurchaseOrderApi.edit(this.purchaseOrderFormData).then(response => {
              this.$message.success('修改成功')
              this.resetPurchaseOrderFormDialog()
              this.handleQuery()
            })
          } else {
            PurchaseOrderApi.add(this.purchaseOrderFormData).then(response => {
              this.$message.success('添加成功')
              this.resetPurchaseOrderFormDialog()
              this.handleQuery()
            })
          }
        }
      })
    },
    resetPurchaseOrderFormDialog() {
      this.purchaseOrderFormDialog = {
        title: '',
        visible: false
      }
      this.purchaseOrderFormData = Object.assign({}, defaultPurchaseOrderFormData)
      this.resetForm('purchaseOrderForm')
    },
    handleSelectionChange(selection) {
      this.multipleSelection = selection
      this.isSingle = selection.length !== 1
      this.isMultiple = !selection.length
    },
    resetQuery() {
      this.page.current = 1
      this.resetForm('queryForm')
      this.handleQuery()
    }
  }
}
</script>
